package com.atguigu.controller;

import com.atguigu.entity.Dict;
import com.atguigu.result.Result;
import com.atguigu.service.DictService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @title：
 * @author：Yu
 * @create：2023-02-20 16:57
 * @description：
 */
@Controller
@ResponseBody
@RequestMapping("/dict")
public class DictController {
    @DubboReference
    private DictService dictService;

    @RequestMapping("/findListByDictCode/{code}")
    public Result findListByCode(@PathVariable String code) {
        List<Dict> byCode = dictService.findByCode(code);
        return Result.ok(byCode);
    }

    @RequestMapping("/findListByParentId/{id}")
    public Result findListByParentId(@PathVariable Long id) {
        List<Dict> byId = dictService.findById(id);
        return Result.ok(byId);
    }
}
